package com.uzai.console.web.md;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.common.utils.Tools;
import com.uzai.console.dto.md.mdexchange.MdExchangeIdDto;
import com.uzai.console.dto.md.mdexchange.MdExchangeQuery;
import com.uzai.console.dto.md.mdexchange.MdExchangeUpdateExptimeDto;
import com.uzai.console.service.md.mdexchange.MdExchangeService;
import com.uzai.console.vo.md.mdexchange.MdExchangeVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "免单兑换记录",tags = "免单管理|免单兑换记录")
@ApiSort(60)
@RestController
public class MdExchangeContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MdExchangeContoller.class);

    @Autowired
    private MdExchangeService mdExchangeService;

    @ApiOperation(value = "查询所有免单兑换记录列表", notes = "查询所有免单兑换记录列表", response = MdExchangeVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/mdExchange/findMdExchangeList")
    public Object findMdExchangeList(@RequestBody MdExchangeQuery mdExchangeQuery){
        //默认查询私有活动兑换记录
        mdExchangeQuery.setSource(Tools.getInteger(mdExchangeQuery.getSource()));
        return mdExchangeService.findMdExchangeList(mdExchangeQuery);
    }

    @ApiOperation(value = "查询免单兑换记录详情", notes = "查询免单兑换记录详情", response = MdExchangeVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/mdExchange/findMdExchange")
    public Object findMdExchange(@RequestBody MdExchangeIdDto mdExchangeIdDto){
        return mdExchangeService.findMdExchange(mdExchangeIdDto);
    }

    @ApiOperation(value = "删除免单兑换记录（未下单）", notes = "删除免单兑换记录（未下单）", response = Boolean.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/mdExchange/deleMdExchange")
    public Object deleMdExchange(@RequestBody MdExchangeIdDto mdExchangeIdDto){
        mdExchangeService.deleMdExchange(mdExchangeIdDto);
        return true;
    }

    @ApiOperation(value = "修改免单兑换记录有效期", notes = "修改免单兑换记录有效期")
    @ApiOperationSupport(order = 3)
    @PostMapping("/mdExchange/updateExptime")
    public Object updateExptime(@RequestBody MdExchangeUpdateExptimeDto mdExchangeUpdateExptimeDto){
        mdExchangeService.updateExptime(mdExchangeUpdateExptimeDto);
        return true;
    }

}
